# Maintainer: David Macek <david.macek.0@gmail.com>

_realname=osslsigncode
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0
pkgrel=1
pkgdesc="Tool for Authenticode signing of PE, CAB and MSI files (mingw-w64)"
arch=('any')
url="https://github.com/mtrojnar/osslsigncode"
license=("GPL3")
depends=("${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libgsf"
         "${MINGW_PACKAGE_PREFIX}-openssl")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/mtrojnar/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('5a60e0a4b3e0b4d655317b2f12a810211c50242138322b16e7e01c6fbb89d92f')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./autogen.sh
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
